home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / CALib & You… / Source / CASample / CAS_Doc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-07  |  5.5 KB  |  203 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CAS_Doc.h
  3.  
  4.     Contains:    Constants and public function prototypes for CAS_doc.c
  5.  
  6.     Written by:    David H Nelson
  7.  
  8.     Copyright © 1993-1995 ComponentWorks, All rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <5>     06/07/95    RB        Adding frameRef fields to the Doc structure
  13.                                      Modifing fileHeader to include embedded frame count
  14.          <4>     04/22/95    DAS        removed #include "CALib.h"
  15.          <4>     03/27/95    DAS        changed Doc_HasDirty() to Doc_SetDirty()
  16.          <3>     03/16/95    RB        Added storageModel field to DocRecord.  Also
  17.                                      added kContainerFileType define.
  18.          <2>     01/17/95    DAS        added Win_IsToolWindow() prototype
  19.          <1>     11/20/93    DHN        Created.
  20. */
  21.  
  22. #if !defined(_H_CAS_Doc)
  23. #define _H_CAS_Doc
  24.  
  25. #include "CAS_Types.h"
  26.  
  27. #include <Printing.h>
  28.  
  29. #ifdef USE_CALIB
  30. #include "CALib.h"
  31. #endif
  32.  
  33. //---------------------------------------------------------------------------
  34. #define kOurFileType        'cafl'
  35. #define kOurFileCreator        'casm'
  36.  
  37. #ifdef USE_CALIB
  38. #define CALIB_SAVVY_DATA_TRANSFER        1
  39. #define kContainerFileType                'cabf'
  40. #define kCASampleKind                    "ComponentWorks:Kind:CASample"
  41. #endif
  42.  
  43. #define MAXITEMCOUNT        100
  44. #define MAXPICTCOUNT        20
  45.  
  46. // These are the "globals" for each window.
  47. struct DocRecord
  48. {
  49.     FSSpec            fileSpec;                // if any
  50.     short            fileRefNum;                // refnum of our file.
  51.     Boolean            fileLocked;                // true if our file is locked.
  52.     Boolean            filler1;
  53.     
  54.     Boolean            changed;                // true if our doc has been changed
  55.  
  56.     THPrint            hPrint;                    // print setup record.
  57.  
  58.     ControlHandle    hScrollBar;                // horiz scroll bar.
  59.     ControlHandle    vScrollBar;                // vert scroll bar.
  60.  
  61.     Rect            hScrollBarRect;            // rect of horiz scroll bar.
  62.     Rect            vScrollBarRect;            // rect of vert scroll bar.
  63.  
  64.     Rect            contentRect;            // content area of window.
  65.     Rect            documentRect;            // total page area of doc.
  66.  
  67.     Handle            undoData;                // the previous state of the doc.
  68.  
  69.     ElemCollPtr        contentColl;
  70.     Point            insertionPoint;
  71.                                             
  72. #ifdef USE_CALIB
  73.     CADocumentRef    partDocRef;
  74.     short            storageModel;            // kNativeStorageModel or kBentoStorageModel
  75. #endif
  76.  
  77. };
  78.  
  79. // This is our file format, followed by an array of itemCount itemRecords
  80. typedef struct 
  81. {
  82. // if you change this, better change kFileVersion below. Set it back to 1 for a final release. 
  83.     short            version;
  84.  
  85.     TPrint            printRecord;            // 
  86.     Rect            windowRect;                // 
  87.     Rect            documentRect;            // 
  88.     short            hScrollValue;            // 
  89.     short            vScrollValue;            // 
  90.     Point            insertionPoint;            // 
  91.     long            elemCount;
  92.  
  93. }
  94. fileHeader;
  95.  
  96. #ifdef USE_CALIB
  97.     #define    kFileVersion        7
  98. #else
  99.     #define    kFileVersion        4
  100. #endif
  101.  
  102. // Internal scrap format
  103. // Both scrap copies and drags pass both kCASScrapType 
  104. // and kPICTType data.
  105. //
  106.     
  107. #define kCASScrapType    'CASS'
  108.  
  109. #ifdef USE_CALIB
  110.     #define kCACASScrapType            'CCAS'
  111.     #define kCACASScrapTypeStr        "CCAS"
  112.     #define kCACASScrapTypeISO        "Apple:OSType:Scrap:CCAS" // The "Apple:OSType:Scrap:" prefix is required
  113. #endif
  114.  
  115. //---------------------------------------------------------------------------
  116. #if defined(__cplusplus)
  117. extern "C"
  118. {
  119. #endif
  120.  
  121.  
  122. void        Doc_InitData(                DocPtr    theDoc );
  123. OSErr        Doc_WriteFile(                DocPtr    theDoc );
  124. OSErr        Doc_ReadFile(                DocPtr    theDoc );
  125.  
  126. // Scrap methods
  127. Handle        Doc_CreateScrapFromSelection(    DocPtr theDoc );
  128. void        Doc_AddItemsFromScrap(            DocPtr theDoc, Handle theScrap, Point origin );
  129.  
  130. // Document methods
  131. Boolean        Doc_GetDirty(                DocPtr theDoc );
  132. void        Doc_SetDirty(                DocPtr theDoc, Boolean isDirty );
  133. OSErr        Doc_SaveAs(                    DocPtr theDoc );
  134. OSErr        Doc_Save(                    DocPtr theDoc );
  135. OSErr        Doc_New(                    void );
  136. void        Doc_Close(                    DocPtr theDoc );
  137. OSErr        Doc_Open(                    FSSpec* theSpec );
  138. void        Doc_SaveUndo(                DocPtr theDoc );
  139. void        Doc_RestoreUndo(            DocPtr theDoc );
  140. void        Doc_DisposeUndo(            DocPtr theDoc );
  141. WindowPtr    Doc_GetWindow(                DocPtr theDoc );
  142. void        Doc_Draw(                    DocPtr theDoc );
  143.  
  144. // Item routines
  145. ElemPtr        Doc_AddItemPict(            DocPtr theDoc, PicHandle thePict, Point thePt );
  146. Boolean        Doc_SelectionExists(        DocPtr theDoc );
  147. void        Doc_SelectAllElements(        DocPtr theDoc, Boolean bSelect );
  148. void        Doc_CalcContentElemRgn(        DocPtr theDoc, RgnHandle theRgn );
  149. short        Doc_GetSelectedFrameCount(    DocPtr theDoc);
  150.  
  151. // Selection routines
  152. void        Doc_DeleteElements(            DocPtr theDoc, ElemListPtr    selectionList );
  153. void        Doc_DeleteCurrentSelection(    DocPtr theDoc );
  154. void        Doc_MoveSelection(            DocPtr theDoc, short offsetH, short offsetV );
  155. void        Doc_CalcSelectionBounds(    DocPtr theDoc, Rect *boundsRect );
  156. void        Doc_CalcContentBounds(        DocPtr theDoc, Rect    *boundsRect );
  157. void        Doc_CalcSelectionRgn(        DocPtr theDoc, RgnHandle theRgn );
  158. PicHandle    Doc_CreateSelectionPicture(    DocPtr theDoc );
  159.  
  160. // Edit Menu Items
  161. void        Doc_UndoMenu(                DocPtr theDoc );
  162. void        Doc_CutMenu(                DocPtr theDoc );
  163. void        Doc_CopyMenu(                DocPtr theDoc, Boolean isCut );
  164. void        Doc_PasteMenu(                DocPtr theDoc );
  165. void        Doc_ClearMenu(                DocPtr theDoc );
  166. void        Doc_SelectAllMenu(            DocPtr theDoc );
  167.  
  168. // Graphics routines
  169. void         Doc_RectDocToGlobal(        DocPtr theDoc, Rect* theRec );
  170. void         Doc_RgnDocToGlobal(            DocPtr theDoc, RgnHandle theRgn );
  171. void        Doc_SetGrafOrigin(            DocPtr theDoc );
  172.  
  173. void        Doc_HandleSelectionRect(    DocPtr theDoc, Point startPt);
  174.  
  175. // CALib Version specific routines
  176.  
  177. #ifdef USE_CALIB
  178.  
  179.  
  180. ElemPtr        Doc_AddEmbeddedFrame(        DocPtr theDoc, CAFrameRef frameRef, Point location);
  181. ElemPtr        Doc_FindElemForFrameRef(    DocPtr theDoc, CAFrameRef frameRef);
  182.  
  183.  
  184. Handle        Doc_CreateCAScrapFromSelection(    DocPtr            theDoc,
  185.                                             CADocumentRef    transferDoc,
  186.                                             CACloneKind        cloneKind);
  187.  
  188. void        Doc_AddItemsFromCAScrap(        DocPtr            theDoc,
  189.                                             Handle            theScrap,
  190.                                             Point*            origin,
  191.                                             CADocumentRef    transferDoc,
  192.                                             CACloneKind        cloneKind);
  193.  
  194. #endif
  195.  
  196. #if defined(__cplusplus)
  197. }
  198. #endif
  199.  
  200.  
  201. #endif
  202.  
  203.